﻿@using FluentBootstrap;

@using (Html.Bootstrap().Container().Begin())
{
    @Html.Bootstrap().Heading1("Readonly")
    using (Html.Bootstrap().Div().SetId("test-readonly").Begin())
    {
        using (var form = Html.Bootstrap().Form().Begin())
        {
            @form.Input("readonly", "Readonly Input", "Initial Value").SetReadonly()
            @form.Input("readonly2", "Normal Input", "Initial Value").SetReadonly(false)
        }
    }
    
    <hr />
    
    @Html.Bootstrap().Heading1("Validation")
    using (Html.Bootstrap().Div().SetId("test-validation").Begin())
    {
        using (var form = Html.Bootstrap().Form().Begin())
        {
            @form.Input("Error", "Error").SetState(ValidationState.Error)
            @form.CheckBox("Warning", "Warning").SetState(ValidationState.Warning)
            @form.Radio("Success", "Success", "Description here").SetState(ValidationState.Success)
        }
    }

    <hr />

    @Html.Bootstrap().Heading1("Inline")
    using (Html.Bootstrap().Div().SetId("test-inline").Begin())
    {
        using (var form = Html.Bootstrap().Form().SetInline().Begin())
        {
            @form.Input("input", "Input")
            @form.Input("b", "B")
            @form.CheckBox("Check", "Check It", "Some text...")
        }
    }

    <hr />

    @Html.Bootstrap().Heading1("Horizontal")
    using (Html.Bootstrap().Div().SetId("test-horizontal").Begin())
    {
        using (var form = Html.Bootstrap().Form().SetHorizontal(6).Begin())
        {
            @form.Input("horizontal", "Horizontal")
            using(form.FormGroup().SetHorizontal(false).Begin())
            {
                @form.Input("not-horizontal", "Not Horizontal")
            }
            using (form.FormGroup().SetAutoColumns(false).Begin())
            {
                @form.ControlLabel("Explicit Widths").SetMd(3)
                @form.Input("explicit-widths").SetMd(9)
            }
            using (form.FormGroup().Begin())
            {
                @form.Input("no-label").SetMd(9)
            }
            using (form.FormGroup().SetMd(8).SetMdOffset(2).Begin())
            {
                @form.Input("group-md", "Group Md")
            }
            @form.CheckBox("Check", "Check It", "Some text...")
        }
    }

    <hr />

    @Html.Bootstrap().Heading1("Horizontal Inline Checked")
    using (Html.Bootstrap().Div().SetId("test-horizontal-inline-checked").Begin())
    {
        using (var form = Html.Bootstrap().Form().SetHorizontal().Begin())
        {
            using (form.FormGroup().Begin())
            {
                @form.CheckBox("a", "A", "Option A").SetInline()
                @form.CheckBox("b", null, "Option B").SetInline()
                @form.CheckBox("c", "C").SetInline()
            }
        }
    }

    <hr />

    @Html.Bootstrap().Heading1("Buttons")
    using (Html.Bootstrap().Div().SetId("test-buttons").Begin())
    {
        using (var form = Html.Bootstrap().Form().Begin())
        {
            @form.InputButton("Input")
            @form.InputButton("Input Submit", buttonType: ButtonType.Submit)
            @form.FormButton("Button")
            @form.FormButton("Button Submit", buttonType: ButtonType.Submit)
            @form.Submit("Submit")
            @form.Reset("Reset")
        }
    }

    <hr />

    @Html.Bootstrap().Heading1("Inline Select")
    using (Html.Bootstrap().Div().SetId("test-inline-select").Begin())
    {
        using (var form = Html.Bootstrap().Form().Begin())
        {
            @form.Select("Select", "Select", "Option A", "Option B", "Option C")
        }
    }

    <hr />

    @Html.Bootstrap().Heading1("Fluent Select")
    using (Html.Bootstrap().Div().SetId("test-fluent-select").Begin())
    {
        using (var form = Html.Bootstrap().Form().Begin())
        {
            @form.Select("Select", "Select").AddOption("Option A", "A").AddOption("Option B", "B", true).AddOption("Option C", "C")
        }
    }

    <hr />

    @Html.Bootstrap().Heading1("Child Select")
    using (Html.Bootstrap().Div().SetId("test-child-select").Begin())
    {
        using (var form = Html.Bootstrap().Form().Begin())
        {
            @(form.Select("Select", "Select")
                .AddChild(x => x.SelectOption("Option A", "A"))
                .AddChild(x => x.SelectOption("Option B", "B", true))
                .AddChild(x => x.SelectOption("Option C", "C")))
        }
    }

    <hr />

    @Html.Bootstrap().Heading1("Form Groups")
    using (Html.Bootstrap().Div().SetId("test-form-groups").Begin())
    {
        using (var form = Html.Bootstrap().Form().Begin())
        {
            @form.Input("With Form Group")
            @form.Input("Without Form Group").EnsureFormGroup(false)
        }
        @Html.Bootstrap().Input("Outside Form")
    }

    <hr />

    @Html.Bootstrap().Heading1("Basic Input Group")
    using (Html.Bootstrap().Div().SetId("test-basic-input-group").Begin())
    {
        using (var form = Html.Bootstrap().Form().Begin())
        {
            using (var inputGroup = form.InputGroup().Begin())
            {
                @inputGroup.InputGroupAddon("@")
                @inputGroup.Input().SetPlaceholder("Username")
            }
            using (var inputGroup = form.InputGroup().Begin())
            {
                @inputGroup.Input()
                @inputGroup.InputGroupAddon(".00")
            }
            using (var inputGroup = form.InputGroup().Begin())
            {
                @inputGroup.InputGroupAddon("$")
                @inputGroup.Input()
                @inputGroup.InputGroupAddon(".00")
            }
        }
    }

    <hr />

    @Html.Bootstrap().Heading1("Input Group Sizing")
    using (Html.Bootstrap().Div().SetId("test-input-group-sizing").Begin())
    {
        using (var form = Html.Bootstrap().Form().Begin())
        {
            using (var inputGroup = form.InputGroup().SetSize(InputGroupSize.Lg).Begin())
            {
                @inputGroup.InputGroupAddon("@")
                @inputGroup.Input().SetPlaceholder("Username")
            }
            using (var inputGroup = form.InputGroup().SetSize(InputGroupSize.Sm).Begin())
            {
                @inputGroup.InputGroupAddon("@")
                @inputGroup.Input().SetPlaceholder("Username")
            }
        }
    }

    <hr />

    @Html.Bootstrap().Heading1("Input Group Checked")
    using (Html.Bootstrap().Div().SetId("test-input-group-checked").Begin())
    {
        using (var form = Html.Bootstrap().Form().Begin())
        {
            using (var inputGroup = form.InputGroup().Begin())
            {
                using (var addon = inputGroup.InputGroupAddon().Begin())
                {
                    @addon.CheckBox()
                }
                @inputGroup.Input()
            }
            using (var inputGroup = form.InputGroup().Begin())
            {
                using (var addon = inputGroup.InputGroupAddon().Begin())
                {
                    @addon.Radio()
                }
                @inputGroup.Input()
            }
        }
    }

    <hr />

    @Html.Bootstrap().Heading1("Input Group Button Addons")
    using (Html.Bootstrap().Div().SetId("test-input-group-button-addons").Begin())
    {
        using (var form = Html.Bootstrap().Form().Begin())
        {
            using (var inputGroup = form.InputGroup().Begin())
            {
                using (var button = inputGroup.InputGroupButton().Begin())
                {
                    @button.Button("Go!")
                }
                @inputGroup.Input()
            }
            using (var inputGroup = form.InputGroup().Begin())
            {
                @inputGroup.Input()
                using (var button = inputGroup.InputGroupButton().Begin())
                {
                    @button.Button("Go!").SetState(ButtonState.Warning)
                }
            }
        }
    }

    <hr />

    @Html.Bootstrap().Heading1("Input Group Button Dropdowns")
    using (Html.Bootstrap().Div().SetId("test-input-group-button-dropdowns").Begin())
    {
        using (var form = Html.Bootstrap().Form().Begin())
        {
            using (var inputGroup = form.InputGroup().Begin())
            {
                using (var button = inputGroup.InputGroupButton().Begin())
                {
                    using (var dropdown = button.Dropdown("Dropdown").Begin())
                    {
                        @dropdown.DropdownLink("A")
                        @dropdown.DropdownLink("B")
                    }
                }
                @inputGroup.Input()
            }
            using (var inputGroup = form.InputGroup().Begin())
            {
                @inputGroup.Input()
                using (var button = inputGroup.InputGroupButton().Begin())
                {
                    using (var dropdown = button.Dropdown("Dropdown").Begin())
                    {
                        @dropdown.DropdownLink("A")
                        @dropdown.DropdownLink("B")
                    }
                }
            }
        }
    }

    <hr />

    @Html.Bootstrap().Heading1("Input Group Segmented Buttons")
    using (Html.Bootstrap().Div().SetId("test-input-group-segmented-buttons").Begin())
    {
        using (var form = Html.Bootstrap().Form().Begin())
        {
            using (var inputGroup = form.InputGroup().Begin())
            {
                using (var button = inputGroup.InputGroupButton().Begin())
                {
                    @button.Button("Action")
                    using (var dropdown = button.Dropdown().Begin())
                    {
                        @dropdown.DropdownLink("A")
                        @dropdown.DropdownLink("B")
                    }
                }
                @inputGroup.Input()
            }
            using (var inputGroup = form.InputGroup().Begin())
            {
                @inputGroup.Input()
                using (var button = inputGroup.InputGroupButton().Begin())
                {
                    @button.Button("Action")
                    using (var dropdown = button.Dropdown().Begin())
                    {
                        @dropdown.DropdownLink("A")
                        @dropdown.DropdownLink("B")
                    }
                }
            }
        }
    }

    <hr />

    @Html.Bootstrap().Heading1("Input Feedback")
    using (Html.Bootstrap().Div().SetId("test-input-feedback").Begin())
    {
        using (var form = Html.Bootstrap().Form().Begin())
        {
            @form.Input("Normal", "Normal").SetFeedback(Icon.OkCircle)
            @form.Input("Error", "Error").SetState(ValidationState.Error).SetFeedback(Icon.RemoveCircle)
            @form.Input("SrOnly").SetState(ValidationState.Warning).SetFeedback(Icon.Check).SetControlLabel("SrOnly Label", x => x.SetVisibility(Visibility.SrOnly))
        }
    }

    <hr />

    @Html.Bootstrap().Heading1("Form Group Feedback")
    using (Html.Bootstrap().Div().SetId("test-form-group-feedback").Begin())
    {
        using (var form = Html.Bootstrap().Form().Begin())
        {
            using (form.FormGroup().SetFeedback(Icon.Music).Begin())
            {
                using (var inputGroup = form.InputGroup().Begin())
                {
                    @inputGroup.InputGroupAddon("@")
                    @inputGroup.Input().SetPlaceholder("Username")
                }
            }
            using (form.FormGroup().SetFeedback(Icon.OkCircle).SetState(ValidationState.Success).Begin())
            {
                using (var inputGroup = form.InputGroup().Begin())
                {
                    @inputGroup.InputGroupAddon("@")
                    @inputGroup.Input().SetPlaceholder("Username")
                }
            }
        }
    }

    <hr />

    @Html.Bootstrap().Heading1("Form Group Horizontal Feedback")
    using (Html.Bootstrap().Div().SetId("test-form-group-horizontal-feedback").Begin())
    {
        using (var form = Html.Bootstrap().Form().SetHorizontal(6).Begin())
        {
            using (form.FormGroup().SetHorizontal(false).SetFeedback(Icon.Open).Begin())
            {
                @form.Input("not-horizontal", "Not Horizontal")
            }
            using (form.FormGroup().SetAutoColumns(false).Begin())
            {
                @form.ControlLabel("Explicit Widths").SetMd(3)
                @form.Input("explicit-widths").SetMd(9).SetFeedback(Icon.Oil)
            }
            using (form.FormGroup().Begin())
            {
                @form.Input("no-label").SetMd(9).SetFeedback(Icon.Sort)
            }
            using (form.FormGroup().SetFeedback(Icon.OkCircle).Begin())
            {
                using (var inputGroup = form.InputGroup().Begin())
                {
                    @inputGroup.InputGroupAddon("@")
                    @inputGroup.Input().SetPlaceholder("Username")
                }
            }
            using (form.FormGroup().SetMd(8).SetMdOffset(2).SetFeedback(Icon.Signal).Begin())
            {
                @form.Input("group-md", "Group Md")
            }
        }
    }
}